// pages/reset/reset.js
import {ajax} from "../../../utils/httpRequest";
import {URI_XIUGAIPASSWORD} from '../../../utils/api'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tel:'',
    pass:'',
    pass1:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      tel:options.tel
    });
  },

  passblur:function(e){
    this.setData({
      pass: e.detail.value
    })
  },

  passblur1: function (e) {
    this.setData({
      pass1: e.detail.value
    })
  },

  resetpass:function(){
    if (this.data.pass && this.data.pass1 && this.data.pass == this.data.pass1){
      ajax.get(URI_XIUGAIPASSWORD,{
        tel: this.data.tel,
        pass: this.data.pass,
        pass1: this.data.pass1
      },{},res=>{
        wx.showModal({
          content:res.msg,
          showCancel:false,
          confirmColor:'#0d77e4',
          success:(res)=>{
            if(res.confirm){
              wx.reLaunch({
                url: '../login/login'
              })
            }
          }
        });
      });
    }else{
      wx.showToast({
        title: '两次输入不一致',
        icon: 'none',
        duration: 2000
      })
    }
  }

})